#import "..\\COM\\Obj\\COM.tlb" no_namespace, rename("GUID","MYGUID"), named_guids
#include <Windows.h>

int main()
{
    HRESULT hResult;
    IDog* lpIDog = nullptr;
    ICat* lpICat = nullptr;
    IPig* lpIPig = nullptr;

    CoInitialize(0);

    do
    {
        hResult = CoCreateInstance(CLSID_ANIMAL, nullptr, CLSCTX_INPROC_SERVER,
            IID_IDog, (void**)&lpIDog);
        if (hResult != S_OK) break;

        hResult = CoCreateInstance(CLSID_ANIMAL, nullptr, CLSCTX_INPROC_SERVER,
            IID_ICat, (void**)&lpICat);
        if (hResult != S_OK) break;

        hResult = CoCreateInstance(CLSID_ANIMAL, nullptr, CLSCTX_INPROC_SERVER,
            IID_IPig, (void**)&lpIPig);
        if (hResult != S_OK) break;

        lpIDog->Call();
        lpICat->Call();
        lpIPig->Call();

    } while (FALSE);

    if (lpIPig)
        lpIPig->Release();

    if (lpICat)
        lpICat->Release();

    if (lpIDog)
        lpIDog->Release();

    CoFreeUnusedLibraries();

    CoUninitialize();

    return 0;
}